/**------------------------------------------------------------
 *
 * Copyright © 2014 rubbervalley. All rights reserved.
 *
 * @Title: FileUtil.java
 * @Package: com.rubbervalley.datacenter.util
 * @Description: TODO
 * @author: angus
 * @date: 下午3:35:41
 * @version: V1.0
 * 
 * Update History:
 * 
 ------------------------------------------------------------*/
package com.rubbervalley.uyo.util;

/**
 * @author angus
 *
 */
public class FileUtil {

	/**
	 * 根据后缀返回excel的类型 
	 * @param fileName
	 * @return 1 xls 2 xlsx
	 */
	public static int checkFiltype(String fileName)
	{
		if(fileName==null) return 0;
		int len = fileName.length();
		int idx= fileName.lastIndexOf('.');
		if(idx!=-1 && idx<len-1)
		{
			String ext = fileName.substring(idx+1,len);
			if(ext.equalsIgnoreCase("xls")) 
			{
				return 1;
			}else if(ext.equalsIgnoreCase("xlsx"))
			{
				return 2;
			}
		}
		return 0;
	}
}
